Change icon-size properties
authorMatthias Clasen <mclasen@redhat.com>
Wed, 15 Nov 2017 19:20:40 +0000 (14:20 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 15 Nov 2017 19:22:17 +0000 (14:22 -0500)
We no longer support registering custom icon sizes, so
we can make these properties just enums. This also lets
us specify them by nick in ui files. Nice!

gtk/gtkimage.c
gtk/gtkstackswitcher.c

index 48968f4e077004c246d77580704b845d4b13506c..f9af644ff6d91493b810137f1bae4f32474def7f 100644 (file)
@@ -174,12 +174,12 @@ gtk_image_class_init (GtkImageClass *class)
                            GTK_PARAM_READWRITE);
 
   image_props[PROP_ICON_SIZE] =
-      g_param_spec_int ("icon-size",
-                        P_("Icon size"),
-                        P_("Symbolic size to use for icon set or named icon"),
-                        0, G_MAXINT,
-                        GTK_ICON_SIZE_INHERIT,
-                        GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+      g_param_spec_enum ("icon-size",
+                         P_("Icon size"),
+                         P_("Symbolic size to use for icon set or named icon"),
+                         GTK_TYPE_ICON_SIZE,
+                         GTK_ICON_SIZE_INHERIT,
+                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
 
   /**
    * GtkImage:pixel-size:
@@ -321,7 +321,7 @@ gtk_image_set_property (GObject      *object,
       gtk_image_set_from_file (image, g_value_get_string (value));
       break;
     case PROP_ICON_SIZE:
-      gtk_image_set_icon_size (image, g_value_get_int (value));
+      gtk_image_set_icon_size (image, g_value_get_enum (value));
       break;
     case PROP_PIXEL_SIZE:
       gtk_image_set_pixel_size (image, g_value_get_int (value));
@@ -368,7 +368,7 @@ gtk_image_get_property (GObject     *object,
       g_value_set_string (value, priv->filename);
       break;
     case PROP_ICON_SIZE:
-      g_value_set_int (value, priv->icon_size);
+      g_value_set_enum (value, priv->icon_size);
       break;
     case PROP_PIXEL_SIZE:
       g_value_set_int (value, _gtk_icon_helper_get_pixel_size (&priv->icon_helper));
@@ -522,7 +522,11 @@ gtk_image_new_from_surface (cairo_surface_t *surface)
  * If the icon name isn’t known, a “broken image” icon will be
  * displayed instead.  If the current icon theme is changed, the icon
  * will be updated appropriately.
- * 
+ *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Returns: a new #GtkImage displaying the themed icon
  *
  * Since: 2.6
@@ -547,7 +551,11 @@ gtk_image_new_from_icon_name (const gchar *icon_name)
  * If the icon name isn’t known, a “broken image” icon will be
  * displayed instead.  If the current icon theme is changed, the icon
  * will be updated appropriately.
- * 
+ *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Returns: a new #GtkImage displaying the themed icon
  *
  * Since: 2.14
@@ -832,6 +840,10 @@ gtk_image_set_from_pixbuf (GtkImage  *image,
  *
  * See gtk_image_new_from_icon_name() for details.
  *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Since: 2.6
  **/
 void
@@ -861,6 +873,10 @@ gtk_image_set_from_icon_name  (GtkImage    *image,
  *
  * See gtk_image_new_from_gicon() for details.
  *
+ * Note: Before 3.94, this function was taking an extra icon size
+ * argument. See gtk_image_set_icon_size() for another way to set
+ * the icon size.
+ *
  * Since: 2.14
  **/
 void
index ebb314906d35a7bc7713293589546a4a76448901..b686998c442629e045189044d15bd28670c8e708 100644 (file)
@@ -27,6 +27,7 @@
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkwidgetprivate.h"
+#include "gtktypebuiltins.h"
 
 /**
  * SECTION:gtkstackswitcher
@@ -65,7 +66,7 @@ struct _GtkStackSwitcherPrivate
 {
   GtkStack *stack;
   GHashTable *buttons;
-  gint icon_size;
+  GtkIconSize icon_size;
   gboolean in_child_changed;
   GtkWidget *switch_button;
   guint switch_timer;
@@ -558,7 +559,7 @@ gtk_stack_switcher_get_stack (GtkStackSwitcher *switcher)
 
 static void
 gtk_stack_switcher_set_icon_size (GtkStackSwitcher *switcher,
-                                  gint              icon_size)
+                                  GtkIconSize       icon_size)
 {
   GtkStackSwitcherPrivate *priv;
 
@@ -593,7 +594,7 @@ gtk_stack_switcher_get_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ICON_SIZE:
-      g_value_set_int (value, priv->icon_size);
+      g_value_set_enum (value, priv->icon_size);
       break;
 
     case PROP_STACK:
@@ -617,7 +618,7 @@ gtk_stack_switcher_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ICON_SIZE:
-      gtk_stack_switcher_set_icon_size (switcher, g_value_get_int (value));
+      gtk_stack_switcher_set_icon_size (switcher, g_value_get_enum (value));
       break;
 
     case PROP_STACK:
@@ -677,12 +678,12 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class)
    */
   g_object_class_install_property (object_class,
                                    PROP_ICON_SIZE,
-                                   g_param_spec_int ("icon-size",
-                                                     P_("Icon Size"),
-                                                     P_("Symbolic size to use for named icon"),
-                                                     0, G_MAXINT,
-                                                     GTK_ICON_SIZE_INHERIT,
-                                                     G_PARAM_EXPLICIT_NOTIFY | GTK_PARAM_READWRITE));
+                                   g_param_spec_enum ("icon-size",
+                                                      P_("Icon Size"),
+                                                      P_("Symbolic size to use for named icon"),
+                                                      GTK_TYPE_ICON_SIZE,
+                                                      GTK_ICON_SIZE_INHERIT,
+                                                      G_PARAM_EXPLICIT_NOTIFY | GTK_PARAM_READWRITE));
 
   g_object_class_install_property (object_class,
                                    PROP_STACK,